<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><link rel="stylesheet" type="text/css" href="style.css" /><script type="text/javascript" src="highlight.js"></script></head><body><pre><span class="hs-pragma">{-# LANGUAGE Unsafe #-}</span><span>
</span><span id="line-2"></span><span class="hs-pragma">{-# LANGUAGE CPP, NoImplicitPrelude, MagicHash, RoleAnnotations #-}</span><span>
</span><span id="line-3"></span><span class="hs-pragma">{-# LANGUAGE UnboxedTuples #-}</span><span>
</span><span id="line-4"></span><span class="hs-pragma">{-# OPTIONS_HADDOCK not-home #-}</span><span>
</span><span id="line-5"></span><span>
</span><span id="line-6"></span><span class="hs-comment">-----------------------------------------------------------------------------</span><span>
</span><span id="line-7"></span><span class="hs-comment">-- |</span><span>
</span><span id="line-8"></span><span class="hs-comment">-- Module      :  GHC.Ptr</span><span>
</span><span id="line-9"></span><span class="hs-comment">-- Copyright   :  (c) The FFI Task Force, 2000-2002</span><span>
</span><span id="line-10"></span><span class="hs-comment">-- License     :  see libraries/base/LICENSE</span><span>
</span><span id="line-11"></span><span class="hs-comment">--</span><span>
</span><span id="line-12"></span><span class="hs-comment">-- Maintainer  :  ffi@haskell.org</span><span>
</span><span id="line-13"></span><span class="hs-comment">-- Stability   :  internal</span><span>
</span><span id="line-14"></span><span class="hs-comment">-- Portability :  non-portable (GHC Extensions)</span><span>
</span><span id="line-15"></span><span class="hs-comment">--</span><span>
</span><span id="line-16"></span><span class="hs-comment">-- The 'Ptr' and 'FunPtr' types and operations.</span><span>
</span><span id="line-17"></span><span class="hs-comment">--</span><span>
</span><span id="line-18"></span><span class="hs-comment">-----------------------------------------------------------------------------</span><span>
</span><span id="line-19"></span><span>
</span><span id="line-20"></span><span class="hs-keyword">module</span><span> </span><span class="hs-identifier">GHC.Ptr</span><span> </span><span class="hs-special">(</span><span>
</span><span id="line-21"></span><span>        </span><span class="annot"><a href="GHC.Ptr.html#Ptr"><span class="hs-identifier">Ptr</span></a></span><span class="hs-special">(</span><span class="hs-glyph">..</span><span class="hs-special">)</span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Ptr.html#FunPtr"><span class="hs-identifier">FunPtr</span></a></span><span class="hs-special">(</span><span class="hs-glyph">..</span><span class="hs-special">)</span><span class="hs-special">,</span><span>
</span><span id="line-22"></span><span>        </span><span class="annot"><a href="GHC.Ptr.html#nullPtr"><span class="hs-identifier">nullPtr</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Ptr.html#castPtr"><span class="hs-identifier">castPtr</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Ptr.html#plusPtr"><span class="hs-identifier">plusPtr</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Ptr.html#alignPtr"><span class="hs-identifier">alignPtr</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Ptr.html#minusPtr"><span class="hs-identifier">minusPtr</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-23"></span><span>        </span><span class="annot"><a href="GHC.Ptr.html#nullFunPtr"><span class="hs-identifier">nullFunPtr</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Ptr.html#castFunPtr"><span class="hs-identifier">castFunPtr</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-24"></span><span>
</span><span id="line-25"></span><span>        </span><span class="annot"><span class="hs-comment">-- * Unsafe functions</span></span><span>
</span><span id="line-26"></span><span>        </span><span class="annot"><a href="GHC.Ptr.html#castFunPtrToPtr"><span class="hs-identifier">castFunPtrToPtr</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Ptr.html#castPtrToFunPtr"><span class="hs-identifier">castPtrToFunPtr</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-27"></span><span>
</span><span id="line-28"></span><span>    </span><span class="hs-special">)</span><span> </span><span class="hs-keyword">where</span><span>
</span><span id="line-29"></span><span>
</span><span id="line-30"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Base.html"><span class="hs-identifier">GHC.Base</span></a></span><span>
</span><span id="line-31"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Show.html"><span class="hs-identifier">GHC.Show</span></a></span><span>
</span><span id="line-32"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Num.html"><span class="hs-identifier">GHC.Num</span></a></span><span>
</span><span id="line-33"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.List.html"><span class="hs-identifier">GHC.List</span></a></span><span> </span><span class="hs-special">(</span><span> </span><span class="annot"><a href="GHC.List.html#length"><span class="hs-identifier">length</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.List.html#replicate"><span class="hs-identifier">replicate</span></a></span><span> </span><span class="hs-special">)</span><span>
</span><span id="line-34"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="Numeric.html"><span class="hs-identifier">Numeric</span></a></span><span>          </span><span class="hs-special">(</span><span> </span><span class="annot"><a href="Numeric.html#showHex"><span class="hs-identifier">showHex</span></a></span><span> </span><span class="hs-special">)</span><span class="hs-cpp">

#include &quot;MachDeps.h&quot;
</span><span>
</span><span id="line-38"></span><span class="hs-comment">------------------------------------------------------------------------</span><span>
</span><span id="line-39"></span><span class="hs-comment">-- Data pointers.</span><span>
</span><span id="line-40"></span><span>
</span><span id="line-41"></span><span class="hs-comment">-- The role of Ptr's parameter is phantom, as there is no relation between</span><span>
</span><span id="line-42"></span><span class="hs-comment">-- the Haskell representation and whathever the user puts at the end of the</span><span>
</span><span id="line-43"></span><span class="hs-comment">-- pointer. And phantom is useful to implement castPtr (see #9163)</span><span>
</span><span id="line-44"></span><span>
</span><span id="line-45"></span><span class="hs-comment">-- redundant role annotation checks that this doesn't change</span><span>
</span><span id="line-46"></span><span class="hs-keyword">type</span><span> </span><span class="hs-keyword">role</span><span> </span><span class="annot"><a href="GHC.Ptr.html#Ptr"><span class="hs-identifier hs-type">Ptr</span></a></span><span> </span><span class="annot"><span class="hs-identifier">phantom</span></span><span>
</span><span id="line-47"></span><span class="hs-keyword">data</span><span> </span><span id="Ptr"><span class="annot"><a href="GHC.Ptr.html#Ptr"><span class="hs-identifier hs-var">Ptr</span></a></span></span><span> </span><span id="local-6989586621679487126"><span class="annot"><a href="#local-6989586621679487126"><span class="hs-identifier hs-type">a</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span id="Ptr"><span class="annot"><a href="GHC.Ptr.html#Ptr"><span class="hs-identifier hs-var">Ptr</span></a></span></span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Prim.html#Addr%23"><span class="hs-identifier hs-type">Addr#</span></a></span><span>
</span><span id="line-48"></span><span>  </span><span class="hs-keyword">deriving</span><span> </span><span class="hs-special">(</span><span> </span><span id="local-6989586621679487046"><span id="local-6989586621679487048"><span class="annot"><span class="annottext">Ptr a -&gt; Ptr a -&gt; Bool
(Ptr a -&gt; Ptr a -&gt; Bool) -&gt; (Ptr a -&gt; Ptr a -&gt; Bool) -&gt; Eq (Ptr a)
forall a. Ptr a -&gt; Ptr a -&gt; Bool
forall a. (a -&gt; a -&gt; Bool) -&gt; (a -&gt; a -&gt; Bool) -&gt; Eq a
/= :: Ptr a -&gt; Ptr a -&gt; Bool
$c/= :: forall a. Ptr a -&gt; Ptr a -&gt; Bool
== :: Ptr a -&gt; Ptr a -&gt; Bool
$c== :: forall a. Ptr a -&gt; Ptr a -&gt; Bool
</span><a href="../../ghc-prim/src/GHC.Classes.html#Eq"><span class="hs-identifier hs-var hs-var hs-var hs-var hs-var hs-var">Eq</span></a></span></span></span><span>  </span><span class="hs-comment">-- ^ @since 2.01</span><span>
</span><span id="line-49"></span><span>           </span><span class="hs-special">,</span><span> </span><span id="local-6989586621679487026"><span id="local-6989586621679487028"><span id="local-6989586621679487031"><span id="local-6989586621679487034"><span id="local-6989586621679487037"><span id="local-6989586621679487039"><span id="local-6989586621679487041"><span class="annot"><span class="annottext">Eq (Ptr a)
Eq (Ptr a)
-&gt; (Ptr a -&gt; Ptr a -&gt; Ordering)
-&gt; (Ptr a -&gt; Ptr a -&gt; Bool)
-&gt; (Ptr a -&gt; Ptr a -&gt; Bool)
-&gt; (Ptr a -&gt; Ptr a -&gt; Bool)
-&gt; (Ptr a -&gt; Ptr a -&gt; Bool)
-&gt; (Ptr a -&gt; Ptr a -&gt; Ptr a)
-&gt; (Ptr a -&gt; Ptr a -&gt; Ptr a)
-&gt; Ord (Ptr a)
Ptr a -&gt; Ptr a -&gt; Bool
Ptr a -&gt; Ptr a -&gt; Ordering
Ptr a -&gt; Ptr a -&gt; Ptr a
forall a. Eq (Ptr a)
forall a.
Eq a
-&gt; (a -&gt; a -&gt; Ordering)
-&gt; (a -&gt; a -&gt; Bool)
-&gt; (a -&gt; a -&gt; Bool)
-&gt; (a -&gt; a -&gt; Bool)
-&gt; (a -&gt; a -&gt; Bool)
-&gt; (a -&gt; a -&gt; a)
-&gt; (a -&gt; a -&gt; a)
-&gt; Ord a
forall a. Ptr a -&gt; Ptr a -&gt; Bool
forall a. Ptr a -&gt; Ptr a -&gt; Ordering
forall a. Ptr a -&gt; Ptr a -&gt; Ptr a
min :: Ptr a -&gt; Ptr a -&gt; Ptr a
$cmin :: forall a. Ptr a -&gt; Ptr a -&gt; Ptr a
max :: Ptr a -&gt; Ptr a -&gt; Ptr a
$cmax :: forall a. Ptr a -&gt; Ptr a -&gt; Ptr a
&gt;= :: Ptr a -&gt; Ptr a -&gt; Bool
$c&gt;= :: forall a. Ptr a -&gt; Ptr a -&gt; Bool
&gt; :: Ptr a -&gt; Ptr a -&gt; Bool
$c&gt; :: forall a. Ptr a -&gt; Ptr a -&gt; Bool
&lt;= :: Ptr a -&gt; Ptr a -&gt; Bool
$c&lt;= :: forall a. Ptr a -&gt; Ptr a -&gt; Bool
&lt; :: Ptr a -&gt; Ptr a -&gt; Bool
$c&lt; :: forall a. Ptr a -&gt; Ptr a -&gt; Bool
compare :: Ptr a -&gt; Ptr a -&gt; Ordering
$ccompare :: forall a. Ptr a -&gt; Ptr a -&gt; Ordering
</span><a href="../../ghc-prim/src/GHC.Classes.html#Ord"><span class="hs-identifier hs-var hs-var hs-var hs-var hs-var hs-var hs-var hs-var hs-var hs-var hs-var hs-var hs-var hs-var hs-var hs-var hs-var">Ord</span></a></span></span></span></span></span></span></span></span><span> </span><span class="hs-comment">-- ^ @since 2.01</span><span>
</span><span id="line-50"></span><span>           </span><span class="hs-special">)</span><span>
</span><span id="line-51"></span><span class="hs-comment">-- ^ A value of type @'Ptr' a@ represents a pointer to an object, or an</span><span>
</span><span id="line-52"></span><span class="hs-comment">-- array of objects, which may be marshalled to or from Haskell values</span><span>
</span><span id="line-53"></span><span class="hs-comment">-- of type @a@.</span><span>
</span><span id="line-54"></span><span class="hs-comment">--</span><span>
</span><span id="line-55"></span><span class="hs-comment">-- The type @a@ will often be an instance of class</span><span>
</span><span id="line-56"></span><span class="hs-comment">-- 'Foreign.Storable.Storable' which provides the marshalling operations.</span><span>
</span><span id="line-57"></span><span class="hs-comment">-- However this is not essential, and you can provide your own operations</span><span>
</span><span id="line-58"></span><span class="hs-comment">-- to access the pointer.  For example you might write small foreign</span><span>
</span><span id="line-59"></span><span class="hs-comment">-- functions to get or set the fields of a C @struct@.</span><span>
</span><span id="line-60"></span><span>
</span><span id="line-61"></span><span class="hs-comment">-- |The constant 'nullPtr' contains a distinguished value of 'Ptr'</span><span>
</span><span id="line-62"></span><span class="hs-comment">-- that is not associated with a valid memory location.</span><span>
</span><span id="line-63"></span><span id="local-6989586621679487124"><span class="annot"><a href="GHC.Ptr.html#nullPtr"><span class="hs-identifier hs-type">nullPtr</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Ptr.html#Ptr"><span class="hs-identifier hs-type">Ptr</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679487124"><span class="hs-identifier hs-type">a</span></a></span></span><span>
</span><span id="line-64"></span><span id="nullPtr"><span class="annot"><span class="annottext">nullPtr :: forall a. Ptr a
</span><a href="GHC.Ptr.html#nullPtr"><span class="hs-identifier hs-var hs-var">nullPtr</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Addr# -&gt; Ptr a
forall a. Addr# -&gt; Ptr a
</span><a href="GHC.Ptr.html#Ptr"><span class="hs-identifier hs-var">Ptr</span></a></span><span> </span><span class="annot"><span class="annottext">Addr#
</span><a href="../../ghc-prim/src/GHC.Prim.html#nullAddr%23"><span class="hs-identifier hs-var">nullAddr#</span></a></span><span>
</span><span id="line-65"></span><span>
</span><span id="line-66"></span><span class="hs-comment">-- |The 'castPtr' function casts a pointer from one type to another.</span><span>
</span><span id="line-67"></span><span id="local-6989586621679487121"><span id="local-6989586621679487122"><span class="annot"><a href="GHC.Ptr.html#castPtr"><span class="hs-identifier hs-type">castPtr</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Ptr.html#Ptr"><span class="hs-identifier hs-type">Ptr</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679487122"><span class="hs-identifier hs-type">a</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Ptr.html#Ptr"><span class="hs-identifier hs-type">Ptr</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679487121"><span class="hs-identifier hs-type">b</span></a></span></span></span><span>
</span><span id="line-68"></span><span id="castPtr"><span class="annot"><span class="annottext">castPtr :: forall a b. Ptr a -&gt; Ptr b
</span><a href="GHC.Ptr.html#castPtr"><span class="hs-identifier hs-var hs-var">castPtr</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Ptr a -&gt; Ptr b
</span><a href="../../ghc-prim/src/GHC.Prim.html#coerce"><span class="hs-identifier hs-var">coerce</span></a></span><span>
</span><span id="line-69"></span><span>
</span><span id="line-70"></span><span class="hs-comment">-- |Advances the given address by the given offset in bytes.</span><span>
</span><span id="line-71"></span><span id="local-6989586621679487114"><span id="local-6989586621679487115"><span class="annot"><a href="GHC.Ptr.html#plusPtr"><span class="hs-identifier hs-type">plusPtr</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Ptr.html#Ptr"><span class="hs-identifier hs-type">Ptr</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679487115"><span class="hs-identifier hs-type">a</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#Int"><span class="hs-identifier hs-type">Int</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Ptr.html#Ptr"><span class="hs-identifier hs-type">Ptr</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679487114"><span class="hs-identifier hs-type">b</span></a></span></span></span><span>
</span><span id="line-72"></span><span id="plusPtr"><span class="annot"><span class="annottext">plusPtr :: forall a b. Ptr a -&gt; Int -&gt; Ptr b
</span><a href="GHC.Ptr.html#plusPtr"><span class="hs-identifier hs-var hs-var">plusPtr</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Ptr.html#Ptr"><span class="hs-identifier hs-type">Ptr</span></a></span><span> </span><span id="local-6989586621679487023"><span class="annot"><span class="annottext">Addr#
</span><a href="#local-6989586621679487023"><span class="hs-identifier hs-var">addr</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-special">(</span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#I%23"><span class="hs-identifier hs-type">I#</span></a></span><span> </span><span id="local-6989586621679487022"><span class="annot"><span class="annottext">Int#
</span><a href="#local-6989586621679487022"><span class="hs-identifier hs-var">d</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Addr# -&gt; Ptr b
forall a. Addr# -&gt; Ptr a
</span><a href="GHC.Ptr.html#Ptr"><span class="hs-identifier hs-var">Ptr</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Addr# -&gt; Int# -&gt; Addr#
</span><a href="../../ghc-prim/src/GHC.Prim.html#plusAddr%23"><span class="hs-identifier hs-var">plusAddr#</span></a></span><span> </span><span class="annot"><span class="annottext">Addr#
</span><a href="#local-6989586621679487023"><span class="hs-identifier hs-var">addr</span></a></span><span> </span><span class="annot"><span class="annottext">Int#
</span><a href="#local-6989586621679487022"><span class="hs-identifier hs-var">d</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-73"></span><span>
</span><span id="line-74"></span><span class="hs-comment">-- |Given an arbitrary address and an alignment constraint,</span><span>
</span><span id="line-75"></span><span class="hs-comment">-- 'alignPtr' yields the next higher address that fulfills the</span><span>
</span><span id="line-76"></span><span class="hs-comment">-- alignment constraint.  An alignment constraint @x@ is fulfilled by</span><span>
</span><span id="line-77"></span><span class="hs-comment">-- any address divisible by @x@.  This operation is idempotent.</span><span>
</span><span id="line-78"></span><span id="local-6989586621679487111"><span class="annot"><a href="GHC.Ptr.html#alignPtr"><span class="hs-identifier hs-type">alignPtr</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Ptr.html#Ptr"><span class="hs-identifier hs-type">Ptr</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679487111"><span class="hs-identifier hs-type">a</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#Int"><span class="hs-identifier hs-type">Int</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Ptr.html#Ptr"><span class="hs-identifier hs-type">Ptr</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679487111"><span class="hs-identifier hs-type">a</span></a></span></span><span>
</span><span id="line-79"></span><span id="alignPtr"><span class="annot"><span class="annottext">alignPtr :: forall a. Ptr a -&gt; Int -&gt; Ptr a
</span><a href="GHC.Ptr.html#alignPtr"><span class="hs-identifier hs-var hs-var">alignPtr</span></a></span></span><span> </span><span id="local-6989586621679487021"><span class="annot"><span class="annottext">addr :: Ptr a
</span><a href="#local-6989586621679487021"><span class="hs-identifier hs-var">addr</span></a></span></span><span class="hs-glyph">@</span><span class="hs-special">(</span><span class="annot"><a href="GHC.Ptr.html#Ptr"><span class="hs-identifier hs-type">Ptr</span></a></span><span> </span><span id="local-6989586621679487020"><span class="annot"><span class="annottext">Addr#
</span><a href="#local-6989586621679487020"><span class="hs-identifier hs-var">a</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-special">(</span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#I%23"><span class="hs-identifier hs-type">I#</span></a></span><span> </span><span id="local-6989586621679487019"><span class="annot"><span class="annottext">Int#
</span><a href="#local-6989586621679487019"><span class="hs-identifier hs-var">i</span></a></span></span><span class="hs-special">)</span><span>
</span><span id="line-80"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">case</span><span> </span><span class="annot"><span class="annottext">Addr# -&gt; Int# -&gt; Int#
</span><a href="../../ghc-prim/src/GHC.Prim.html#remAddr%23"><span class="hs-identifier hs-var">remAddr#</span></a></span><span> </span><span class="annot"><span class="annottext">Addr#
</span><a href="#local-6989586621679487020"><span class="hs-identifier hs-var">a</span></a></span><span> </span><span class="annot"><span class="annottext">Int#
</span><a href="#local-6989586621679487019"><span class="hs-identifier hs-var">i</span></a></span><span> </span><span class="hs-keyword">of</span><span> </span><span class="hs-special">{</span><span>
</span><span id="line-81"></span><span>      </span><span class="annot"><span class="annottext">Int#
</span><span class="hs-number">0#</span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">Ptr a
</span><a href="#local-6989586621679487021"><span class="hs-identifier hs-var">addr</span></a></span><span class="hs-special">;</span><span>
</span><span id="line-82"></span><span>      </span><span id="local-6989586621679487018"><span class="annot"><span class="annottext">Int#
</span><a href="#local-6989586621679487018"><span class="hs-identifier hs-var">n</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">Addr# -&gt; Ptr a
forall a. Addr# -&gt; Ptr a
</span><a href="GHC.Ptr.html#Ptr"><span class="hs-identifier hs-var">Ptr</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Addr# -&gt; Int# -&gt; Addr#
</span><a href="../../ghc-prim/src/GHC.Prim.html#plusAddr%23"><span class="hs-identifier hs-var">plusAddr#</span></a></span><span> </span><span class="annot"><span class="annottext">Addr#
</span><a href="#local-6989586621679487020"><span class="hs-identifier hs-var">a</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Int#
</span><a href="#local-6989586621679487019"><span class="hs-identifier hs-var">i</span></a></span><span> </span><span class="annot"><span class="annottext">Int# -&gt; Int# -&gt; Int#
</span><a href="../../ghc-prim/src/GHC.Prim.html#-%23"><span class="hs-operator hs-var">-#</span></a></span><span> </span><span class="annot"><span class="annottext">Int#
</span><a href="#local-6989586621679487018"><span class="hs-identifier hs-var">n</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-83"></span><span>
</span><span id="line-84"></span><span class="hs-comment">-- |Computes the offset required to get from the second to the first</span><span>
</span><span id="line-85"></span><span class="hs-comment">-- argument.  We have</span><span>
</span><span id="line-86"></span><span class="hs-comment">--</span><span>
</span><span id="line-87"></span><span class="hs-comment">-- &gt; p2 == p1 `plusPtr` (p2 `minusPtr` p1)</span><span>
</span><span id="line-88"></span><span id="local-6989586621679487108"><span id="local-6989586621679487109"><span class="annot"><a href="GHC.Ptr.html#minusPtr"><span class="hs-identifier hs-type">minusPtr</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Ptr.html#Ptr"><span class="hs-identifier hs-type">Ptr</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679487109"><span class="hs-identifier hs-type">a</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Ptr.html#Ptr"><span class="hs-identifier hs-type">Ptr</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679487108"><span class="hs-identifier hs-type">b</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#Int"><span class="hs-identifier hs-type">Int</span></a></span></span></span><span>
</span><span id="line-89"></span><span id="minusPtr"><span class="annot"><span class="annottext">minusPtr :: forall a b. Ptr a -&gt; Ptr b -&gt; Int
</span><a href="GHC.Ptr.html#minusPtr"><span class="hs-identifier hs-var hs-var">minusPtr</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Ptr.html#Ptr"><span class="hs-identifier hs-type">Ptr</span></a></span><span> </span><span id="local-6989586621679487017"><span class="annot"><span class="annottext">Addr#
</span><a href="#local-6989586621679487017"><span class="hs-identifier hs-var">a1</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Ptr.html#Ptr"><span class="hs-identifier hs-type">Ptr</span></a></span><span> </span><span id="local-6989586621679487016"><span class="annot"><span class="annottext">Addr#
</span><a href="#local-6989586621679487016"><span class="hs-identifier hs-var">a2</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Int# -&gt; Int
</span><a href="../../ghc-prim/src/GHC.Types.html#I%23"><span class="hs-identifier hs-var">I#</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Addr# -&gt; Addr# -&gt; Int#
</span><a href="../../ghc-prim/src/GHC.Prim.html#minusAddr%23"><span class="hs-identifier hs-var">minusAddr#</span></a></span><span> </span><span class="annot"><span class="annottext">Addr#
</span><a href="#local-6989586621679487017"><span class="hs-identifier hs-var">a1</span></a></span><span> </span><span class="annot"><span class="annottext">Addr#
</span><a href="#local-6989586621679487016"><span class="hs-identifier hs-var">a2</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-90"></span><span>
</span><span id="line-91"></span><span class="hs-comment">------------------------------------------------------------------------</span><span>
</span><span id="line-92"></span><span class="hs-comment">-- Function pointers for the default calling convention.</span><span>
</span><span id="line-93"></span><span>
</span><span id="line-94"></span><span class="hs-comment">-- 'FunPtr' has a phantom role for similar reasons to 'Ptr'.</span><span>
</span><span id="line-95"></span><span class="hs-keyword">type</span><span> </span><span class="hs-keyword">role</span><span> </span><span class="annot"><a href="GHC.Ptr.html#FunPtr"><span class="hs-identifier hs-type">FunPtr</span></a></span><span> </span><span class="annot"><span class="hs-identifier">phantom</span></span><span>
</span><span id="line-96"></span><span class="hs-keyword">data</span><span> </span><span id="FunPtr"><span class="annot"><a href="GHC.Ptr.html#FunPtr"><span class="hs-identifier hs-var">FunPtr</span></a></span></span><span> </span><span id="local-6989586621679487105"><span class="annot"><a href="#local-6989586621679487105"><span class="hs-identifier hs-type">a</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span id="FunPtr"><span class="annot"><a href="GHC.Ptr.html#FunPtr"><span class="hs-identifier hs-var">FunPtr</span></a></span></span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Prim.html#Addr%23"><span class="hs-identifier hs-type">Addr#</span></a></span><span> </span><span class="hs-keyword">deriving</span><span> </span><span class="hs-special">(</span><span id="local-6989586621679487011"><span id="local-6989586621679487013"><span class="annot"><span class="annottext">FunPtr a -&gt; FunPtr a -&gt; Bool
(FunPtr a -&gt; FunPtr a -&gt; Bool)
-&gt; (FunPtr a -&gt; FunPtr a -&gt; Bool) -&gt; Eq (FunPtr a)
forall a. FunPtr a -&gt; FunPtr a -&gt; Bool
forall a. (a -&gt; a -&gt; Bool) -&gt; (a -&gt; a -&gt; Bool) -&gt; Eq a
/= :: FunPtr a -&gt; FunPtr a -&gt; Bool
$c/= :: forall a. FunPtr a -&gt; FunPtr a -&gt; Bool
== :: FunPtr a -&gt; FunPtr a -&gt; Bool
$c== :: forall a. FunPtr a -&gt; FunPtr a -&gt; Bool
</span><a href="../../ghc-prim/src/GHC.Classes.html#Eq"><span class="hs-identifier hs-var hs-var hs-var hs-var hs-var hs-var">Eq</span></a></span></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621679486992"><span id="local-6989586621679486994"><span id="local-6989586621679486997"><span id="local-6989586621679487000"><span id="local-6989586621679487003"><span id="local-6989586621679487005"><span id="local-6989586621679487007"><span class="annot"><span class="annottext">Eq (FunPtr a)
Eq (FunPtr a)
-&gt; (FunPtr a -&gt; FunPtr a -&gt; Ordering)
-&gt; (FunPtr a -&gt; FunPtr a -&gt; Bool)
-&gt; (FunPtr a -&gt; FunPtr a -&gt; Bool)
-&gt; (FunPtr a -&gt; FunPtr a -&gt; Bool)
-&gt; (FunPtr a -&gt; FunPtr a -&gt; Bool)
-&gt; (FunPtr a -&gt; FunPtr a -&gt; FunPtr a)
-&gt; (FunPtr a -&gt; FunPtr a -&gt; FunPtr a)
-&gt; Ord (FunPtr a)
FunPtr a -&gt; FunPtr a -&gt; Bool
FunPtr a -&gt; FunPtr a -&gt; Ordering
FunPtr a -&gt; FunPtr a -&gt; FunPtr a
forall a. Eq (FunPtr a)
forall a.
Eq a
-&gt; (a -&gt; a -&gt; Ordering)
-&gt; (a -&gt; a -&gt; Bool)
-&gt; (a -&gt; a -&gt; Bool)
-&gt; (a -&gt; a -&gt; Bool)
-&gt; (a -&gt; a -&gt; Bool)
-&gt; (a -&gt; a -&gt; a)
-&gt; (a -&gt; a -&gt; a)
-&gt; Ord a
forall a. FunPtr a -&gt; FunPtr a -&gt; Bool
forall a. FunPtr a -&gt; FunPtr a -&gt; Ordering
forall a. FunPtr a -&gt; FunPtr a -&gt; FunPtr a
min :: FunPtr a -&gt; FunPtr a -&gt; FunPtr a
$cmin :: forall a. FunPtr a -&gt; FunPtr a -&gt; FunPtr a
max :: FunPtr a -&gt; FunPtr a -&gt; FunPtr a
$cmax :: forall a. FunPtr a -&gt; FunPtr a -&gt; FunPtr a
&gt;= :: FunPtr a -&gt; FunPtr a -&gt; Bool
$c&gt;= :: forall a. FunPtr a -&gt; FunPtr a -&gt; Bool
&gt; :: FunPtr a -&gt; FunPtr a -&gt; Bool
$c&gt; :: forall a. FunPtr a -&gt; FunPtr a -&gt; Bool
&lt;= :: FunPtr a -&gt; FunPtr a -&gt; Bool
$c&lt;= :: forall a. FunPtr a -&gt; FunPtr a -&gt; Bool
&lt; :: FunPtr a -&gt; FunPtr a -&gt; Bool
$c&lt; :: forall a. FunPtr a -&gt; FunPtr a -&gt; Bool
compare :: FunPtr a -&gt; FunPtr a -&gt; Ordering
$ccompare :: forall a. FunPtr a -&gt; FunPtr a -&gt; Ordering
</span><a href="../../ghc-prim/src/GHC.Classes.html#Ord"><span class="hs-identifier hs-var hs-var hs-var hs-var hs-var hs-var hs-var hs-var hs-var hs-var hs-var hs-var hs-var hs-var hs-var hs-var hs-var">Ord</span></a></span></span></span></span></span></span></span></span><span class="hs-special">)</span><span>
</span><span id="line-97"></span><span class="hs-comment">-- ^ A value of type @'FunPtr' a@ is a pointer to a function callable</span><span>
</span><span id="line-98"></span><span class="hs-comment">-- from foreign code.  The type @a@ will normally be a /foreign type/,</span><span>
</span><span id="line-99"></span><span class="hs-comment">-- a function type with zero or more arguments where</span><span>
</span><span id="line-100"></span><span class="hs-comment">--</span><span>
</span><span id="line-101"></span><span class="hs-comment">-- * the argument types are /marshallable foreign types/,</span><span>
</span><span id="line-102"></span><span class="hs-comment">--   i.e. 'Char', 'Int', 'Double', 'Float',</span><span>
</span><span id="line-103"></span><span class="hs-comment">--   'Bool', 'Data.Int.Int8', 'Data.Int.Int16', 'Data.Int.Int32',</span><span>
</span><span id="line-104"></span><span class="hs-comment">--   'Data.Int.Int64', 'Data.Word.Word8', 'Data.Word.Word16',</span><span>
</span><span id="line-105"></span><span class="hs-comment">--   'Data.Word.Word32', 'Data.Word.Word64', @'Ptr' a@, @'FunPtr' a@,</span><span>
</span><span id="line-106"></span><span class="hs-comment">--   @'Foreign.StablePtr.StablePtr' a@ or a renaming of any of these</span><span>
</span><span id="line-107"></span><span class="hs-comment">--   using @newtype@.</span><span>
</span><span id="line-108"></span><span class="hs-comment">--</span><span>
</span><span id="line-109"></span><span class="hs-comment">-- * the return type is either a marshallable foreign type or has the form</span><span>
</span><span id="line-110"></span><span class="hs-comment">--   @'IO' t@ where @t@ is a marshallable foreign type or @()@.</span><span>
</span><span id="line-111"></span><span class="hs-comment">--</span><span>
</span><span id="line-112"></span><span class="hs-comment">-- A value of type @'FunPtr' a@ may be a pointer to a foreign function,</span><span>
</span><span id="line-113"></span><span class="hs-comment">-- either returned by another foreign function or imported with a</span><span>
</span><span id="line-114"></span><span class="hs-comment">-- a static address import like</span><span>
</span><span id="line-115"></span><span class="hs-comment">--</span><span>
</span><span id="line-116"></span><span class="hs-comment">-- &gt; foreign import ccall &quot;stdlib.h &amp;free&quot;</span><span>
</span><span id="line-117"></span><span class="hs-comment">-- &gt;   p_free :: FunPtr (Ptr a -&gt; IO ())</span><span>
</span><span id="line-118"></span><span class="hs-comment">--</span><span>
</span><span id="line-119"></span><span class="hs-comment">-- or a pointer to a Haskell function created using a /wrapper/ stub</span><span>
</span><span id="line-120"></span><span class="hs-comment">-- declared to produce a 'FunPtr' of the correct type.  For example:</span><span>
</span><span id="line-121"></span><span class="hs-comment">--</span><span>
</span><span id="line-122"></span><span class="hs-comment">-- &gt; type Compare = Int -&gt; Int -&gt; Bool</span><span>
</span><span id="line-123"></span><span class="hs-comment">-- &gt; foreign import ccall &quot;wrapper&quot;</span><span>
</span><span id="line-124"></span><span class="hs-comment">-- &gt;   mkCompare :: Compare -&gt; IO (FunPtr Compare)</span><span>
</span><span id="line-125"></span><span class="hs-comment">--</span><span>
</span><span id="line-126"></span><span class="hs-comment">-- Calls to wrapper stubs like @mkCompare@ allocate storage, which</span><span>
</span><span id="line-127"></span><span class="hs-comment">-- should be released with 'Foreign.Ptr.freeHaskellFunPtr' when no</span><span>
</span><span id="line-128"></span><span class="hs-comment">-- longer required.</span><span>
</span><span id="line-129"></span><span class="hs-comment">--</span><span>
</span><span id="line-130"></span><span class="hs-comment">-- To convert 'FunPtr' values to corresponding Haskell functions, one</span><span>
</span><span id="line-131"></span><span class="hs-comment">-- can define a /dynamic/ stub for the specific foreign type, e.g.</span><span>
</span><span id="line-132"></span><span class="hs-comment">--</span><span>
</span><span id="line-133"></span><span class="hs-comment">-- &gt; type IntFunction = CInt -&gt; IO ()</span><span>
</span><span id="line-134"></span><span class="hs-comment">-- &gt; foreign import ccall &quot;dynamic&quot;</span><span>
</span><span id="line-135"></span><span class="hs-comment">-- &gt;   mkFun :: FunPtr IntFunction -&gt; IntFunction</span><span>
</span><span id="line-136"></span><span>
</span><span id="line-137"></span><span class="hs-comment">-- |The constant 'nullFunPtr' contains a</span><span>
</span><span id="line-138"></span><span class="hs-comment">-- distinguished value of 'FunPtr' that is not</span><span>
</span><span id="line-139"></span><span class="hs-comment">-- associated with a valid memory location.</span><span>
</span><span id="line-140"></span><span id="local-6989586621679487104"><span class="annot"><a href="GHC.Ptr.html#nullFunPtr"><span class="hs-identifier hs-type">nullFunPtr</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Ptr.html#FunPtr"><span class="hs-identifier hs-type">FunPtr</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679487104"><span class="hs-identifier hs-type">a</span></a></span></span><span>
</span><span id="line-141"></span><span id="nullFunPtr"><span class="annot"><span class="annottext">nullFunPtr :: forall a. FunPtr a
</span><a href="GHC.Ptr.html#nullFunPtr"><span class="hs-identifier hs-var hs-var">nullFunPtr</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Addr# -&gt; FunPtr a
forall a. Addr# -&gt; FunPtr a
</span><a href="GHC.Ptr.html#FunPtr"><span class="hs-identifier hs-var">FunPtr</span></a></span><span> </span><span class="annot"><span class="annottext">Addr#
</span><a href="../../ghc-prim/src/GHC.Prim.html#nullAddr%23"><span class="hs-identifier hs-var">nullAddr#</span></a></span><span>
</span><span id="line-142"></span><span>
</span><span id="line-143"></span><span class="hs-comment">-- |Casts a 'FunPtr' to a 'FunPtr' of a different type.</span><span>
</span><span id="line-144"></span><span id="local-6989586621679487101"><span id="local-6989586621679487102"><span class="annot"><a href="GHC.Ptr.html#castFunPtr"><span class="hs-identifier hs-type">castFunPtr</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Ptr.html#FunPtr"><span class="hs-identifier hs-type">FunPtr</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679487102"><span class="hs-identifier hs-type">a</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Ptr.html#FunPtr"><span class="hs-identifier hs-type">FunPtr</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679487101"><span class="hs-identifier hs-type">b</span></a></span></span></span><span>
</span><span id="line-145"></span><span id="castFunPtr"><span class="annot"><span class="annottext">castFunPtr :: forall a b. FunPtr a -&gt; FunPtr b
</span><a href="GHC.Ptr.html#castFunPtr"><span class="hs-identifier hs-var hs-var">castFunPtr</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">FunPtr a -&gt; FunPtr b
</span><a href="../../ghc-prim/src/GHC.Prim.html#coerce"><span class="hs-identifier hs-var">coerce</span></a></span><span>
</span><span id="line-146"></span><span>
</span><span id="line-147"></span><span class="hs-comment">-- |Casts a 'FunPtr' to a 'Ptr'.</span><span>
</span><span id="line-148"></span><span class="hs-comment">--</span><span>
</span><span id="line-149"></span><span class="hs-comment">-- /Note:/ this is valid only on architectures where data and function</span><span>
</span><span id="line-150"></span><span class="hs-comment">-- pointers range over the same set of addresses, and should only be used</span><span>
</span><span id="line-151"></span><span class="hs-comment">-- for bindings to external libraries whose interface already relies on</span><span>
</span><span id="line-152"></span><span class="hs-comment">-- this assumption.</span><span>
</span><span id="line-153"></span><span id="local-6989586621679487097"><span id="local-6989586621679487098"><span class="annot"><a href="GHC.Ptr.html#castFunPtrToPtr"><span class="hs-identifier hs-type">castFunPtrToPtr</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Ptr.html#FunPtr"><span class="hs-identifier hs-type">FunPtr</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679487098"><span class="hs-identifier hs-type">a</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Ptr.html#Ptr"><span class="hs-identifier hs-type">Ptr</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679487097"><span class="hs-identifier hs-type">b</span></a></span></span></span><span>
</span><span id="line-154"></span><span id="castFunPtrToPtr"><span class="annot"><span class="annottext">castFunPtrToPtr :: forall a b. FunPtr a -&gt; Ptr b
</span><a href="GHC.Ptr.html#castFunPtrToPtr"><span class="hs-identifier hs-var hs-var">castFunPtrToPtr</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Ptr.html#FunPtr"><span class="hs-identifier hs-type">FunPtr</span></a></span><span> </span><span id="local-6989586621679486990"><span class="annot"><span class="annottext">Addr#
</span><a href="#local-6989586621679486990"><span class="hs-identifier hs-var">addr</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Addr# -&gt; Ptr b
forall a. Addr# -&gt; Ptr a
</span><a href="GHC.Ptr.html#Ptr"><span class="hs-identifier hs-var">Ptr</span></a></span><span> </span><span class="annot"><span class="annottext">Addr#
</span><a href="#local-6989586621679486990"><span class="hs-identifier hs-var">addr</span></a></span><span>
</span><span id="line-155"></span><span>
</span><span id="line-156"></span><span class="hs-comment">-- |Casts a 'Ptr' to a 'FunPtr'.</span><span>
</span><span id="line-157"></span><span class="hs-comment">--</span><span>
</span><span id="line-158"></span><span class="hs-comment">-- /Note:/ this is valid only on architectures where data and function</span><span>
</span><span id="line-159"></span><span class="hs-comment">-- pointers range over the same set of addresses, and should only be used</span><span>
</span><span id="line-160"></span><span class="hs-comment">-- for bindings to external libraries whose interface already relies on</span><span>
</span><span id="line-161"></span><span class="hs-comment">-- this assumption.</span><span>
</span><span id="line-162"></span><span id="local-6989586621679487093"><span id="local-6989586621679487094"><span class="annot"><a href="GHC.Ptr.html#castPtrToFunPtr"><span class="hs-identifier hs-type">castPtrToFunPtr</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Ptr.html#Ptr"><span class="hs-identifier hs-type">Ptr</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679487094"><span class="hs-identifier hs-type">a</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Ptr.html#FunPtr"><span class="hs-identifier hs-type">FunPtr</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679487093"><span class="hs-identifier hs-type">b</span></a></span></span></span><span>
</span><span id="line-163"></span><span id="castPtrToFunPtr"><span class="annot"><span class="annottext">castPtrToFunPtr :: forall a b. Ptr a -&gt; FunPtr b
</span><a href="GHC.Ptr.html#castPtrToFunPtr"><span class="hs-identifier hs-var hs-var">castPtrToFunPtr</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Ptr.html#Ptr"><span class="hs-identifier hs-type">Ptr</span></a></span><span> </span><span id="local-6989586621679486989"><span class="annot"><span class="annottext">Addr#
</span><a href="#local-6989586621679486989"><span class="hs-identifier hs-var">addr</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Addr# -&gt; FunPtr b
forall a. Addr# -&gt; FunPtr a
</span><a href="GHC.Ptr.html#FunPtr"><span class="hs-identifier hs-var">FunPtr</span></a></span><span> </span><span class="annot"><span class="annottext">Addr#
</span><a href="#local-6989586621679486989"><span class="hs-identifier hs-var">addr</span></a></span><span>
</span><span id="line-164"></span><span>
</span><span id="line-165"></span><span class="hs-comment">------------------------------------------------------------------------</span><span>
</span><span id="line-166"></span><span class="hs-comment">-- Show instances for Ptr and FunPtr</span><span>
</span><span id="line-167"></span><span>
</span><span id="line-168"></span><span class="hs-comment">-- | @since 2.01</span><span>
</span><span id="line-169"></span><span id="local-6989586621679487088"><span class="hs-keyword">instance</span><span> </span><span id="local-6989586621679486984"><span id="local-6989586621679486986"><span class="annot"><a href="GHC.Show.html#Show"><span class="hs-identifier hs-type">Show</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Ptr.html#Ptr"><span class="hs-identifier hs-type">Ptr</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679487088"><span class="hs-identifier hs-type">a</span></a></span><span class="hs-special">)</span></span></span><span> </span><span class="hs-keyword">where</span><span>
</span><span id="line-170"></span><span>   </span><span id="local-6989586621679486978"><span class="annot"><span class="annottext">showsPrec :: Int -&gt; Ptr a -&gt; ShowS
</span><a href="GHC.Show.html#showsPrec"><span class="hs-identifier hs-var hs-var hs-var hs-var">showsPrec</span></a></span></span><span> </span><span class="annot"><span class="annottext">Int
</span><span class="hs-identifier">_</span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Ptr.html#Ptr"><span class="hs-identifier hs-type">Ptr</span></a></span><span> </span><span id="local-6989586621679486976"><span class="annot"><span class="annottext">Addr#
</span><a href="#local-6989586621679486976"><span class="hs-identifier hs-var">a</span></a></span></span><span class="hs-special">)</span><span> </span><span id="local-6989586621679486975"><span class="annot"><span class="annottext">String
</span><a href="#local-6989586621679486975"><span class="hs-identifier hs-var">rs</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">ShowS
</span><a href="#local-6989586621679486974"><span class="hs-identifier hs-var">pad_out</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Integer -&gt; ShowS
forall a. (Integral a, Show a) =&gt; a -&gt; ShowS
</span><a href="Numeric.html#showHex"><span class="hs-identifier hs-var">showHex</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Word# -&gt; Integer
</span><a href="../../ghc-bignum/src/GHC.Num.Integer.html#integerFromWord%23"><span class="hs-identifier hs-var">integerFromWord#</span></a></span><span class="hs-special">(</span><span class="annot"><span class="annottext">Int# -&gt; Word#
</span><a href="../../ghc-prim/src/GHC.Prim.html#int2Word%23"><span class="hs-identifier hs-var">int2Word#</span></a></span><span class="hs-special">(</span><span class="annot"><span class="annottext">Addr# -&gt; Int#
</span><a href="../../ghc-prim/src/GHC.Prim.html#addr2Int%23"><span class="hs-identifier hs-var">addr2Int#</span></a></span><span> </span><span class="annot"><span class="annottext">Addr#
</span><a href="#local-6989586621679486976"><span class="hs-identifier hs-var">a</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;&quot;</span></span><span class="hs-special">)</span><span>
</span><span id="line-171"></span><span>     </span><span class="hs-keyword">where</span><span>
</span><span id="line-172"></span><span>        </span><span class="hs-comment">-- want 0s prefixed to pad it out to a fixed length.</span><span>
</span><span id="line-173"></span><span>       </span><span id="local-6989586621679486974"><span class="annot"><span class="annottext">pad_out :: ShowS
</span><a href="#local-6989586621679486974"><span class="hs-identifier hs-var hs-var">pad_out</span></a></span></span><span> </span><span id="local-6989586621679486968"><span class="annot"><span class="annottext">String
</span><a href="#local-6989586621679486968"><span class="hs-identifier hs-var">ls</span></a></span></span><span> </span><span class="hs-glyph">=</span><span>
</span><span id="line-174"></span><span>          </span><span class="annot"><span class="annottext">Char
</span><span class="hs-char">'0'</span></span><span class="annot"><span class="annottext">Char -&gt; ShowS
forall a. a -&gt; [a] -&gt; [a]
</span><a href="../../ghc-prim/src/GHC.Types.html#%3A"><span class="hs-glyph hs-var">:</span></a></span><span class="annot"><span class="annottext">Char
</span><span class="hs-char">'x'</span></span><span class="annot"><span class="annottext">Char -&gt; ShowS
forall a. a -&gt; [a] -&gt; [a]
</span><a href="../../ghc-prim/src/GHC.Types.html#%3A"><span class="hs-glyph hs-var">:</span></a></span><span class="hs-special">(</span><span class="annot"><span class="annottext">Int -&gt; Char -&gt; String
forall a. Int -&gt; a -&gt; [a]
</span><a href="GHC.List.html#replicate"><span class="hs-identifier hs-var">replicate</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Int
</span><span class="hs-number">2</span></span><span class="annot"><span class="annottext">Int -&gt; Int -&gt; Int
forall a. Num a =&gt; a -&gt; a -&gt; a
</span><a href="GHC.Num.html#%2A"><span class="hs-operator hs-var">*</span></a></span><span class="hs-identifier">SIZEOF_HSPTR</span><span> </span><span class="hs-glyph">-</span><span> </span><span class="hs-identifier">length</span><span> </span><span class="hs-identifier">ls</span><span class="hs-special">)</span><span> </span><span class="hs-char">'0'</span><span class="hs-special">)</span><span> </span></span><span class="hs-operator">++</span><span> </span><span class="hs-identifier">ls</span><span> </span><span class="hs-operator">++</span><span> </span><span class="hs-identifier">rs</span><span>
</span><span id="line-175"></span><span>
</span><span id="line-176"></span><span class="hs-comment">-- | @since 2.01</span><span>
</span><span id="line-177"></span><span id="local-6989586621679487082"><span class="hs-keyword">instance</span><span> </span><span id="local-6989586621679486962"><span id="local-6989586621679486964"><span class="annot"><a href="GHC.Show.html#Show"><span class="hs-identifier hs-type">Show</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Ptr.html#FunPtr"><span class="hs-identifier hs-type">FunPtr</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679487082"><span class="hs-identifier hs-type">a</span></a></span><span class="hs-special">)</span></span></span><span> </span><span class="hs-keyword">where</span><span>
</span><span id="line-178"></span><span>   </span><span id="local-6989586621679486960"><span class="annot"><span class="annottext">showsPrec :: Int -&gt; FunPtr a -&gt; ShowS
</span><a href="#local-6989586621679486960"><span class="hs-identifier hs-var hs-var hs-var hs-var">showsPrec</span></a></span></span><span> </span><span id="local-6989586621679486959"><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679486959"><span class="hs-identifier hs-var">p</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Int -&gt; Ptr Any -&gt; ShowS
forall a. Show a =&gt; Int -&gt; a -&gt; ShowS
</span><a href="GHC.Show.html#showsPrec"><span class="hs-identifier hs-var">showsPrec</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679486959"><span class="hs-identifier hs-var">p</span></a></span><span> </span><span class="annot"><span class="annottext">(Ptr Any -&gt; ShowS) -&gt; (FunPtr a -&gt; Ptr Any) -&gt; FunPtr a -&gt; ShowS
forall b c a. (b -&gt; c) -&gt; (a -&gt; b) -&gt; a -&gt; c
</span><a href="GHC.Base.html#."><span class="hs-operator hs-var">.</span></a></span><span> </span><span class="annot"><span class="annottext">FunPtr a -&gt; Ptr Any
forall a b. FunPtr a -&gt; Ptr b
</span><a href="GHC.Ptr.html#castFunPtrToPtr"><span class="hs-identifier hs-var">castFunPtrToPtr</span></a></span></span><span>
</span><span id="line-179"></span></pre></body></html>